
<?
	  include("/inc/header.html") {}
    ?>
                                    <div class="row">
                                        <div class="col-lg-12">
                                            <div class="panel panel">       
                                                <div class="panel-body pan" style="height: 420px">                                                                          
                                                        <div class="form-body pal" >
                                                            <div >
                                                                <label for="inputUsername" class="col-md-3 control-label">数据导出名称 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="name" type="text" class="form-control"  />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                            <div>
                                                             <label for="inputUsername" class="col-md-3 control-label">数据导出描述 <span class='require'>*</span>
                                                                </label>
                                                                <div class="col-md-9">
                                                                    <div class="input-icon">
                                                                        <input id="description" type="text"class="form-control" />
                                                                    </div>
                                                                </div>
                                                            </div>
                                                                   <div >
							                                        <label for="inputUsername" class="col-md-3 control-label">数据源名称<span class='require' >*</span> </label>
							                                         <div class="col-md-9">
								                                         <div class="input-group input-group-sm mbs" >
									                                         <input id="shujuname" type="text" placeholder=""  class="form-control" disabled="true"  />
									                                           <span class="input-group-btn"><button  onclick="shuju()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">选择...</button></span>		
									                                           <input id="dataSourceId" type="hidden" value="00" class="form-control" />
								                                       </div>
							                                      </div>
                                                              <div >
						                                        <label for="inputUsername" class="col-md-3 control-label">知识库名称<span class='require' >*</span> </label>
						                                         <div class="col-md-9">
							                                         <div class="input-group input-group-sm mbs" >
								                                         <input id="parentclassname" type="text" placeholder=""  class="form-control" disabled="true"  />
								                                                     <span class="input-group-btn"><button  onclick="saveclassZTree()" type="button" data-toggle="dropdown" class="btn btn-success dropdown-toggle">选择...</button></span>		
								                                           <input id="parentClassid" type="hidden" value="00" class="form-control" />
							                                      	 </div>
						                                     	 </div>
                                                       		 </div>
                                                       		<div >
						                                        <label class="col-md-3 control-label">用户<span class='require' >*</span> </label>
						                                         <div class="col-md-9">
							                                         <div class="input-group input-group-sm mbs" >
																		<div class='col-md-9'>
																			<div class="input-icon" style="height:110px; overflow:auto" id="userbox">
																				
																			</div>
																		</div>
							                                      	 </div>
						                                     	 </div>
                                                       		 </div>
                                                </div>
                                            </div>
                                         </div></div>
                                  </div></div>
           
  <script type="text/javascript">
  $(function(){ 
  	  $.ajax({  
            type : "post",  
            url : "exportUser.do",  
            dataType : "json", 
            async:false,  
            success : function(data) { 
                var str = '<label for="Allcheckall" name="Allcheckall" onclick="selectAll(this)">全选</label>&nbsp;&nbsp;<input type="checkbox" id="Allcheckall" onclick="selectAll(this)"/><br/>';   
                for(var i=0;i<data.length;i++){
                	str+='<input type="checkbox" id="user_'+data[i].id+'" name="checkall" value="'+data[i].id+'" />&nbsp;&nbsp;<label for="user_'+data[i].id+'" name="checkall">'+data[i].nickname+'</label>&nbsp;&nbsp;';
                }
                 $("#userbox").html(str);
            },
         error : function(data) {
               alert("请求失败");
      }
        });
  	
  })
  //数据源
	function shuju() {
		parent.layer.open({
			type : 2,
			area : [ '700px', '500px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			//move : false,
			title:"选择数据源",
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : ["data-import-source-from.html?winName="+window.name, 'no'],
			yes : function(index,layer) {		
			  var iframeWin = parent.window[layer.find('iframe')[0]['name']];
			   iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	};
 	function saveclassZTree() {
		parent.layer.open({
			type : 2,
			area : [ '400px', '400px' ],
			fix : false, //不固定
			scrollbar : false,
			shadeClose : true,
			//move : false,
			title:"导出数据的类",
			skin : 'layui-layer-rim', //加上边框
			btn : [ '保存 ', '关闭' ],
			content : ["knowledge-Classes-class-zTree.html?winName="+window.name, 'no'],
			yes : function(index,layer) {		
			  var iframeWin = parent.window[layer.find('iframe')[0]['name']];
			  			  iframeWin.save();
			},
			cancel : function(index) {
			}
		});
	};
	 
function save() {  
             if($.trim($("#name").val()).length<1) {
 	        	alert('数据导出名称不能为空！');
 	        	return null;
 	        }
   	         if($.trim($("#description").val()).length<1) {
   	        	alert('数据导出描述不能为空！');
   	        	return null;
   	        }
   	         if($.trim($("#dataSourceId").val()).length<1) {
   	        	alert('数据来源不能为空！');
   	        	return null;
   	        }
   	        if($("#parentClassid").val()==0) {
   	        	alert('所属类不能为空！');
   	        	return null;
   	        }   
   	     var value=[];
			$("input[name='checkall']:checked").each(function(){
			value.push($(this).val());
		});  
		 if(value.length == 0) {
   	        	alert('用户不能为空！');
   	        	return null;
   	        }  
   		 $.ajax({  
                type : "post",  
                url : "./KnowledgeExportsave.do",  
                data : {
                "name":$("#name").val(),
                "description":$("#description").val(),
                "dataSourceId":$("#dataSourceId").val(),
                "classesId":$("#parentClassid").val(),
                "value" :value
                },
                dataType : "json", 
                traditional : true,
                async:false,  
                success : function(data) { 
                     var index = parent.layer.getFrameIndex(window.name); 
			          	window.parent.get();
			            parent.layer.msg('添加或编辑成功');
			            parent.layer.close(index); 
                },
	            error : function(data) {
                   alert("请求失败");
		        }
            });

          
    }  
 function selectAll(obj){
		if($(obj).is(":checked")){
			$("input[name=checkall]").each(function(){
				   $(this).prop("checked", "true");
				});
		}else{
			$("input[name=checkall]").each(function(){
				   $(this).removeAttr("checked");
				});
		}
	}
  
</script>


